Skip to content

Conversation

@5Amogh
Copy link
Member

@5Amogh 5Amogh commented Jan 7, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Added feedback functionality with dedicated interface
    • CHO report button now accessible in doctor worklist
    • Enhanced diagnosis search with lazy-loading and improved suggestions
    • High-risk pregnancy visual indicators in nurse worklist
    • Additional beneficiary details now displayed (father name, last name, preferred phone number)
  • Improvements

    • Better error handling with user-friendly fallback messages
    • Session management and language persistence enhancements
    • Improved autocomplete interactions across forms
    • Enhanced diagnostic tools with loading states
  • Version

    • Updated to version 3.6.0

✏️ Tip: You can customize this high-level summary in your review settings.

Abhijeet and others added 30 commits July 5, 2025 20:16
fix: aam-1725 provisional diagnosis rendering issue fix and performance improvement by n facto
5Amogh and others added 25 commits December 8, 2025 13:32
feat: amm-1959 enabling cho reports btn
feat: amm-1959 added missing url in ci script for env
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 7, 2026

📝 Walkthrough

Walkthrough

This PR introduces comprehensive tracking and analytics integration across the application via AmritTrackingService, implements lazy-loading autocomplete functionality for diagnosis fields, enhances HTTP error handling with robust session management, adds new UI elements (CHO report button, feedback link, high-risk indicators), and updates environment configurations alongside language translations.

Changes

Cohort / File(s) Summary
Tracking Service Integration
src/app/app.component.ts, src/app/app.module.ts, src/app/user-login/login/login.component.ts, src/app/app-modules/core/components/app-header/*, src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/*, src/app/app-modules/nurse-doctor/examination/general-opd-examination/*, src/app/app-modules/nurse-doctor/history/general-opd-history/*, src/app/app-modules/nurse-doctor/visit-details/*, src/app/app-modules/nurse-doctor/vitals/*, src/app/app-modules/nurse-doctor/refer/general-refer/*
Added AmritTrackingService injection and trackFieldInteraction() method to 30+ components; wired TrackingModule.forRoot() in app module; set user ID on login; instrumented templates with click, focus, and change event tracking across forms
Diagnosis Autocomplete & Pagination
src/app/app-modules/nurse-doctor/shared/utility/autocomplete-scroller.directive.ts, src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/general-opd-diagnosis/*, src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-care-diagnosis/*, src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-screening-diagnosis/*, src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/pnc-diagnosis/*, src/app/app-modules/nurse-doctor/quick-consult/*
Introduced new AutocompleteScrollerDirective for infinite-scroll behavior; refactored diagnosis search to support per-index lazy-loading pagination with state management (pageByIndex, loadingMore, noMore, wantMore); added onPanelReady and onAutoNearEnd lifecycle hooks; replaced direct searches with fetchPage method supporting incremental loading
HTTP Interceptor & Session Management
src/app/app-modules/core/services/http-interceptor.service.ts, src/app/app-modules/core/services/http-service.service.ts
Enhanced error handling for 401, 403, 500 status codes with session-expiry prompts; added platform-feedback request special handling (remove auth header); implemented language-based message fallbacks; added localStorage persistence for app language; improved session state cleanup on errors
App Layout & Navigation
src/app/app-modules/core/components/app-footer/app-footer.component.html, src/app/app-modules/core/components/app-header/app-header.component.ts
Changed app footer column widths (col-4 to col-3) and added Feedback block with mail icon linking to /feedback?sl=AAM; updated app header logout redirect from login to /feedback?sl=HWC; added click tracking for role-based navigation
Worklist & Report Features
src/app/app-modules/nurse-doctor/doctor-worklist/*, src/app/app-modules/nurse-doctor/nurse-worklist-wrapper/nurse-worklist/*, src/app/app-modules/lab/worklist/worklist.component.ts, src/app/app-modules/pharmacist/worklist/worklist.component.ts
Added CHO report button controlled by enableCHOReportBtn flag with DHIS URL navigation; introduced high-risk pregnancy row styling (.marker-h-r-c class) and indicator; added err?.handled guard to skip duplicate alerts in error handlers
Beneficiary & Case Sheet Details
src/app/app-modules/core/components/beneficiary-details/beneficiary-details.component.html, src/app/app-modules/nurse-doctor/case-sheet/general-case-sheet/doctor-diagnosis-case-sheet/doctor-diagnosis-case-sheet.component.ts
Added conditional UI blocks for fatherName, lastName, preferredPhoneNum fields in beneficiary details; introduced userName tracking and getUserId() method to retrieve user ID for signature downloads instead of fixed ID
Environment & Configuration
src/environments/*.ts, scripts/ci-prebuild.js, src/app/app-routing.module.ts
Added tracking configuration block (platform, siteId, trackerUrl, trackingPlatform, enabled) across all environment files; added enableCHOReportBtn and dhisURL properties; exposed getUserId endpoint; added new CI prebuild environment variables (SITE_ID, TRACKER_URL, TRACKING_ENABLED, etc.); added lazy-loaded feedback route
Localization
src/assets/English.json, src/assets/Hindi.json, src/assets/Assamese.json, src/assets/Kannada.json
Added new platform_feedback translation object with 10 keys; added bendetails.lastName field; added Reports.choReport key; added alerts.info entries (beneficiaryNotFound, accessDenied, internaleServerError, somethingWentWrong)
Test & Lab Components
src/app/app-modules/nurse-doctor/case-record/general-case-record/test-and-radiology/test-and-radiology.component.html
Replaced ng-container wrappers with actual div elements in table column iteration, potentially affecting layout/styling
Version & Dependencies
pom.xml, .gitmodules
Updated Maven version from 3.1.0 to 3.6.0; updated Common-UI submodule commit reference

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Component
    participant AutocompleteScroller
    participant MasterdataService
    participant UI as Mat-Autocomplete

    User->>Component: Focus on diagnosis input
    Component->>Component: onDiagnosisInputKeyup() trim & reset state
    Component->>Component: Initialize pageByIndex=0, lastQuery
    
    Component->>MasterdataService: fetchPage(index, append=false)
    MasterdataService-->>Component: diagnosis results (page 0)
    Component->>UI: Update suggestedDiagnosisList
    Component->>Component: loadingMore[i]=false
    
    UI->>AutocompleteScroller: Panel opens
    AutocompleteScroller->>Component: onPanelReady(i, panelEl)
    Component->>Component: bootstrapUntilScrollable()
    
    loop Until scrollable or limit
        Component->>MasterdataService: fetchPage(i, append=true)
        MasterdataService-->>Component: next page results
        Component->>UI: Append deduplicated results
    end
    
    User->>UI: Scroll near bottom
    AutocompleteScroller->>Component: onAutoNearEnd(i)
    Component->>MasterdataService: fetchPage(i, append=true)
    MasterdataService-->>Component: results
    Component->>UI: Append & update noMore flag
    
    User->>UI: Select diagnosis
    UI->>Component: onDiagnosisSelected()
    Component->>Component: Update form model
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • feat: Added Matomo User Analytics in HWC-UI #151: Adds Matomo/Common-UI tracking integration with TrackingModule imports, AmritTrackingService injections across components, environment tracking configuration, and CI prebuild environment variables matching this PR's pattern.

Suggested reviewers

  • snehar-nd
  • drtechie

Poem

🐰 Hops through code with tracking glee,
Diagnoses scroll lazily,
Feedback links and high-risk gleams,
Error handling, session dreams—
Analytics bloom, feedback complete,
Version bumped, the upgrade's sweet! 🎯

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Release 3.6.0 into main' clearly summarizes the primary objective of merging the release version 3.6.0 into the main branch.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom Pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 7, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
27.6% Duplication on New Code (required ≤ 3%)
D Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 12

Note

Due to the large number of review comments, Critical, Major severity comments were prioritized as inline comments.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/app/user-login/login/login.component.ts (1)

224-236: Remove duplicate sessionStorage assignment.

Lines 224-227 and 233-236 both set loginDataResponse in session storage with identical data (userLoggedIn.data). The first assignment (lines 224-227) is redundant.

🔎 Proposed fix
                          .subscribe((userLoggedIn: any) => {
                            if (userLoggedIn.statusCode === 200) {
                              if (userLoggedIn?.data?.previlegeObj[0]) {
-                                this.sessionstorage.setItem(
-                                  'loginDataResponse',
-                                  JSON.stringify(userLoggedIn.data),
-                                );
                                this.trackingService.setUserId(
                                  userLoggedIn.data.userID,
                                );
                                this.authService.sessionExpiredHandled =
                                  false;
                                this.sessionstorage.setItem(
                                  'loginDataResponse',
                                  JSON.stringify(userLoggedIn.data),
                                );
                                this.getServicesAuthdetails(
                                  userLoggedIn.data,
                                );
🤖 Fix all issues with AI agents
In @src/app/app-modules/core/components/app-footer/app-footer.component.html:
- Line 3: Add the missing "platform_feedback" translation object into
Kannada.json so the footer feedback link uses localized text; replicate the same
keys used in other locale files (e.g., "title" and any subkeys used for the
feedback link) under the "platform_feedback" key in Kannada.json with
appropriate Kannada strings so it matches English/Hindi/Assamese structure.

In
@src/app/app-modules/core/components/beneficiary-details/beneficiary-details.component.html:
- Around line 23-52: The three conditional display sections for
beneficiary?.fatherName, beneficiary?.lastName and
beneficiary?.preferredPhoneNum that use current_language_set?.bendetails labels
are only present in the benFlowStatus=true table; add the same three
<ng-container *ngIf="..."> blocks (using the same ids: fatherName, lastName,
phoneNo and the same label lookups current_language_set?.bendetails?.fatherName
/ ?.lastName / ?.phoneNo) into the alternate table block that renders when
benFlowStatus is false so both flow branches show the same fields consistently.

In @src/app/app-modules/core/services/http-interceptor.service.ts:
- Around line 90-113: The code currently clears sessionStorage on every HTTP
error; instead, remove the unconditional sessionStorage.clear() and
this.sessionstorage.clear() calls and call them only inside the 401 and 403
branches where you invoke handleSessionExpiry (i.e., after the
handleSessionExpiry call in the blocks handling error.status === 401 and
error.status === 403) so users aren’t logged out on transient errors; also
change usage of this.currentLanguageSet.internaleServerError to a correct key
(fix the typo to internalServerError) and provide a fallback string like
this.currentLanguageSet.internalServerError || 'Internal server error. Please
try again later.' so the 500 branch behaves like the others.

In
@src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/diagnosis.component.ts:
- Line 26: The import for AmritTrackingService is unresolved; update the import
in the DiagnosisComponent (where AmritTrackingService is referenced) to point to
the actual module that exports it (replace 'Common-UI/src/tracking' with the
correct package/path that contains AmritTrackingService), or if Common-UI should
be a dependency, add/restore the Common-UI package and its tracking export and
update tsconfig paths accordingly; ensure the symbol AmritTrackingService is
exported from the target module and update any usages in the component to match
the corrected import.

In
@src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/general-opd-diagnosis/general-opd-diagnosis.component.ts:
- Around line 401-412: The error handler currently leaves loadingMore[index] set
to true and blocks further pagination; update the error callback inside the
subscription in general-opd-diagnosis.component.ts to (1) accept the error
param, (2) log the actual error (e.g., console.error('Error fetching diagnosis
data', err)), and (3) reset loadingMore[index] = false and wantMore[index] =
false so the index is not permanently blocked; keep noMore[index] untouched and
do not call fetchPage there (the complete path handles chaining).

In
@src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-care-diagnosis/ncd-care-diagnosis.component.ts:
- Around line 385-437: In fetchPage(...) the error handler only logs the failure
and leaves loadingMore[index] true, which can block further fetches; modify the
error callback in the subscribe of
masterdataService.searchDiagnosisBasedOnPageNo to set this.loadingMore[index] =
false (and also this.wantMore[index] = false if applicable) and optionally set
this.noMore[index] = true or handle retry state, ensuring the same index state
cleanup as done in the complete handler so subsequent calls to fetchPage can
proceed.

In
@src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-screening-diagnosis/ncd-screening-diagnosis.component.ts:
- Around line 679-690: The error handler in the subscription callback for
NcdScreeningDiagnosisComponent fails to reset the pagination flags, so when an
error occurs loadingMore[index] remains true and blocks further fetches; update
the error: handler to set loadingMore[index] = false and wantMore[index] = false
(matching the complete: behavior) so the UI can attempt pagination again,
referencing the same arrays/indices used in the complete block (loadingMore,
wantMore, noMore) and ensuring fetchPage(index, true) is only called from
complete when wantChain is true.

In
@src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/pnc-diagnosis/pnc-diagnosis.component.ts:
- Around line 553-598: The fetchPage method lacks error handling and cleanup:
add an error handler to the Observable.subscribe call to log/set state on
network errors (update the subscribe call in fetchPage to include an error:
(err) => { s.loadingMore[index]=false; s.wantMore[index]=false;
s.noMore[index]=true/false as appropriate; and log or surface the error } ), and
prevent leaks by tying the request lifecycle to the component destruction—either
store the returned Subscription from subscribe and unsubscribe it in
ngOnDestroy, or (preferred) introduce a private destroy$ = new Subject<void>()
on the component and replace .subscribe(...) with
.pipe(takeUntil(this.destroy$)).subscribe({...}) and then in ngOnDestroy call
this.destroy$.next(); this.destroy$.complete(); so any in-flight fetchPage
requests are cancelled when the component is destroyed.

In
@src/app/app-modules/nurse-doctor/doctor-worklist/doctor-worklist.component.ts:
- Around line 119-121: In redirectToCHOReport, add robust validation and error
handling: wrap JSON.parse(this.sessionstorage.getItem('loginDataResponse')) in a
try/catch and handle a null/invalid value; verify environment.dhisURL is a
non-empty string and that the parsed object contains a non-empty dhistoken
before building the URL; if checks fail, emit a user-facing error (e.g., show a
toast/alert or call an existing logger) and return early; before setting
window.location.href prompt the user for confirmation (confirm dialog or modal)
and only navigate when confirmed. Ensure to reference the existing
redirectToCHOReport method, sessionstorage.getItem('loginDataResponse'),
environment.dhisURL and dhistoken when making these changes.

In
@src/app/app-modules/nurse-doctor/history/general-opd-history/family-history/family-history.component.html:
- Line 185: The template incorrectly uses the (selectionChange) event on an
<input> element so trackFieldInteraction('Genetic Disorder Type') never fires;
update the binding on that input to a supported event such as (input) or
(change) (e.g., replace (selectionChange) with (input) or (change)) so the
trackFieldInteraction call is invoked when the input value changes; confirm you
are editing the template line containing the <input> with the
trackFieldInteraction call and not a <mat-select> element.

In @src/app/app-modules/nurse-doctor/shared/services/doctor.service.ts:
- Around line 3024-3026: Add a missing environment key and tighten types: add a
getUserId: string entry to all standard environment files (dev, development,
local, prod, test) so environment.getUserId exists at runtime, then update the
doctor service method signature getUserId(userName: any) to use a concrete
parameter type (e.g., userName: string) and a typed Observable return (e.g.,
Observable<any> or a specific interface like Observable<{userId: string}>), and
call HttpClient.get with the generic type and a safe concatenation/encoding of
environment.getUserId + userName; refer to the getUserId method and
environment.getUserId symbol names when making these changes.

In @src/app/app-modules/pharmacist/worklist/worklist.component.ts:
- Around line 151-153: The if (err?.handled) check in worklist.component.ts is
dead because the HTTP interceptor's intercept method currently does
throwError(error.error) without setting handled; either remove this unused
conditional from the component so the alert always runs, or update the
interceptor's intercept (or its error handling path) to attach a handled: true
flag onto the error object it emits (e.g., wrap/clone error.error as {
...error.error, handled: true } before calling throwError) so the component can
rely on err.handled to suppress alerts.
🟡 Minor comments (10)
src/assets/Hindi.json-1194-1194 (1)

1194-1194: Fix typo in testresult translation.

There's an extra "t" character at the end of the Hindi translation. The value should be "जाँच परिणाम" instead of "जाँच परिणामt".

🔎 Proposed fix
-      "testresult": "जाँच परिणामt",
+      "testresult": "जाँच परिणाम",
src/assets/Kannada.json-2137-2137 (1)

2137-2137: Potential typo in translation key name.

The key name internaleServerError appears to have a typo - it should likely be internalServerError (missing the 'l' before 'Server'). This inconsistency could cause issues when the frontend code tries to reference this translation key.

🔎 Suggested fix
-        "internaleServerError": "ಆಂತರಿಕ ಸರ್ವರ್ ದೋಷ",
+        "internalServerError": "ಆಂತರಿಕ ಸರ್ವರ್ ದೋಷ",
src/assets/English.json-2134-2134 (1)

2134-2134: Fix typo in translation key.

The key internaleServerError contains a typo. It should be internalServerError (note the missing 'l' before 'S' in "Internal"). This typo could cause confusion and may require code changes if corrected later.

🔎 Proposed fix
-        "internaleServerError": "Internal Server Error",
+        "internalServerError": "Internal Server Error",
src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-screening-diagnosis/ncd-screening-diagnosis.component.html-20-20 (1)

20-20: Validation is handled programmatically but only at button state level—consider enforcing at form control level.

The required attribute removal is balanced by checkProvisionalDiagnosisValidity(), which correctly validates that both term and conceptID are populated. However, this validation only disables the Add button and does not mark the form control as invalid. The form control itself has no required validator, so the form could be submitted as valid even if no diagnosis is selected when enableProvisionalDiag is true. Either add Validators.required to the form control conditionally, or implement form-level validation to ensure incomplete provisional diagnoses are caught at submission.

src/environments/environment.test.ts-73-79 (1)

73-79: Use explicit HTTP protocol for the test tracker URL instead of protocol-relative format.

Matomo documentation explicitly advises against protocol-relative URLs for tracker configuration due to mixed-content warnings, caching issues, and reduced security. For test environments on localhost, use http://127.0.0.1/ instead of //127.0.0.1/.

src/environments/environment.ci.ts.template-59-65 (1)

59-65: Ensure SITE_ID template variable is always numeric during deployment

The siteId field uses parseInt('<%= SITE_ID %>'). While ci-prebuild.js provides a default value of '1', the variable can be overridden by environment variables. If an empty string or non-numeric value is passed, parseInt() will silently return NaN, breaking Matomo tracking. Add validation or document that SITE_ID must always be a numeric string during the build/deployment process.

src/app/app-modules/nurse-doctor/quick-consult/quick-consult.component.ts-1472-1482 (1)

1472-1482: Add validation for deduplication key fields

The deduplication logic relies on items having at least one of id, code, or term, but there is no validation that ensures this. Items lacking all three fields would be keyed as undefined, causing multiple malformed records to incorrectly deduplicate as a single entry. Consider adding a fallback deduplication key (e.g., object stringification) or explicit validation to handle items that lack all three identifiers.

src/app/app-modules/nurse-doctor/case-sheet/general-case-sheet/doctor-diagnosis-case-sheet/doctor-diagnosis-case-sheet.component.ts-583-603 (1)

583-603: Handle potential null userId before downloading signature.

If getUserId() returns null (when res?.userId is falsy) and tCSpecialistUserID is also missing/zero, downloadSign will be called with null, which could cause the API call to fail or return unexpected results.

🔎 Suggested fix
 downloadSign() {
   this.getUserId().subscribe((userId) => {
     const tcSpecId = this.beneficiaryDetails?.tCSpecialistUserID;
     const userIdToUse = tcSpecId && tcSpecId !== 0 ? tcSpecId : userId;
+    if (!userIdToUse) {
+      console.warn('No valid user ID available for signature download');
+      return;
+    }
     this.doctorService.downloadSign(userIdToUse).subscribe(
       (response: any) => {
         const blob = new Blob([response], { type: response.type });
         this.showSign(blob);
       },
       (err: any) => {
         console.error('Error downloading signature:', err);
       },
     );
   });
 }
src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-screening-diagnosis/ncd-screening-diagnosis.component.ts-552-554 (1)

552-554: Missing optional chaining on unsubscribe() call.

Unlike GeneralOpdDiagnosisComponent which uses unsubscribe?.(), this component calls unsubscribe() directly. Since MMUdiagnosisSubscription is typed as any, it could throw if the subscription completed abnormally or was never initialized. Consider using optional chaining for consistency and safety.

🔎 Proposed fix
    if (this.MMUdiagnosisSubscription) {
-     this.MMUdiagnosisSubscription.unsubscribe();
+     this.MMUdiagnosisSubscription.unsubscribe?.();
    }
src/app/app.component.ts-4-4 (1)

4-4: Remove the unused AmritTrackingService import and injection, and delete the debug console.log.

AmritTrackingService is imported and injected in the constructor but never used in the component. Other components across the codebase actively call trackFieldInteraction() or setUserId() on this service, but AppComponent has no such calls. Additionally, the console.log('success') in ngOnInit should be removed.

🧹 Nitpick comments (21)
src/assets/Kannada.json (1)

2135-2138: Consider organizing these keys under a subsection for consistency.

The new translation keys (continueButton, accessDenied, internalServerError, somethingWentWrong) are placed directly at the root Kannada object level, while similar error/alert messages throughout the file are organized under the alerts.info section (see line 1193 for example).

For better maintainability and consistency with the existing structure, consider moving these keys to an appropriate subsection like alerts.info or creating a new logical grouping (e.g., common.buttons, common.errors).

Example organization approach
         "alerts": {
             "info": {
                 "beneficiaryNotFound": "ಫಲಾನುಭವಿಯು ಡೇಟಾ ಕಂಡುಬಂದಿಲ್ಲ",
+                "accessDenied": "ಪ್ರವೇಶ ನಿರಾಕರಿಸಲಾಗಿದೆ",
+                "internalServerError": "ಆಂತರಿಕ ಸರ್ವರ್ ದೋಷ",
+                "somethingWentWrong": "ಏನೋ ತಪ್ಪಾಗಿದೆ",
                 ...
             }
         },
+        "common": {
+            "continueButton": "ಮುಂದುವರಿಸಿ",
+            ...
+        }
src/app/app-modules/nurse-doctor/history/general-opd-history/personal-history/personal-history.component.html (2)

10-696: Consider using constants for tracking field names.

The tracking calls use string literals throughout (e.g., 'Previous Tobacco History', 'Dietary Type'). Consider defining these as constants to prevent typos and improve maintainability.

Example approach

In the component TypeScript file, define constants:

const TRACKING_FIELDS = {
  PREVIOUS_TOBACCO: 'Previous Tobacco History',
  PREVIOUS_ALCOHOL: 'Previous Alcohol History',
  DIETARY_TYPE: 'Dietary Type',
  // ... etc
} as const;

Then use in the template:

(click)="getPreviousTobaccoHistory(); trackFieldInteraction(TRACKING_FIELDS.PREVIOUS_TOBACCO)"

However, since template expressions have limited access to component properties, you may need to expose these constants via a getter or use them in component methods instead.


256-666: Consider the volume of tracking events being generated.

Tracking has been added to high-frequency events including focus handlers on multiple input fields. While valuable for analytics, this could generate substantial telemetry data, especially in busy clinical environments.

Consider:

  • Whether focus events are necessary for your analytics goals, or if change/blur events would suffice
  • Implementing sampling or throttling for high-frequency events
  • Monitoring the performance and storage impact of the tracking service
src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/pnc-diagnosis/pnc-diagnosis.component.html (1)

65-69: Move inline styles to CSS file.

The flexbox centering styles are duplicated in both the provisional and confirmatory diagnosis sections. Extract these to a reusable CSS class in the component's stylesheet for better maintainability.

🔎 Proposed fix

Add to pnc-diagnosis.component.css:

.diagnosis-button-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

Then update the template:

-              style="
-                display: flex;
-                justify-content: center;
-                align-items: center;
-              "
+              class="diagnosis-button-container"

Also applies to: 168-172

src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/pnc-diagnosis/pnc-diagnosis.component.ts (1)

441-458: Consider using a typed interface for state management.

The state object uses parallel arrays indexed by position, which can be error-prone. The arrays are not pre-initialized, so accessing state.provisional.suggested[i] when index i hasn't been used yet returns undefined.

🔎 Proposed improvement with typed interface
interface DiagnosisState {
  suggested: any[];
  lastQuery: string;
  page: number;
  loadingMore: boolean;
  noMore: boolean;
  wantMore: boolean;
}

state: {
  provisional: Map<number, DiagnosisState>;
  confirmatory: Map<number, DiagnosisState>;
} = {
  provisional: new Map(),
  confirmatory: new Map(),
};

// Helper to get or create state for an index
private getOrCreateState(type: 'provisional' | 'confirmatory', index: number): DiagnosisState {
  const map = this.state[type];
  if (!map.has(index)) {
    map.set(index, {
      suggested: [],
      lastQuery: '',
      page: 0,
      loadingMore: false,
      noMore: false,
      wantMore: false,
    });
  }
  return map.get(index)!;
}
src/app/app-modules/nurse-doctor/shared/utility/autocomplete-scroller.directive.ts (1)

67-67: Consider refactoring to avoid non-null assertion.

The non-null assertion on this.scrollListener! at line 67 is technically safe since the listener is assigned just above on line 58. However, to address the linter warning and improve code clarity, consider this refactor:

🔎 Proposed refactor to eliminate non-null assertion
         this.ngZone.runOutsideAngular(() => {
-          this.scrollListener = () => {
+          const listener = () => {
             if (panelEl.scrollHeight <= panelEl.clientHeight) return; // no overflow yet
             const ratio =
               (panelEl.scrollTop + panelEl.clientHeight) / panelEl.scrollHeight;
             if (ratio >= this.threshold) {
               // hop back into Angular so change detection works
               this.ngZone.run(() => this.nearEnd.emit());
             }
           };
-          panelEl.addEventListener('scroll', this.scrollListener!, {
+          this.scrollListener = listener;
+          panelEl.addEventListener('scroll', listener, {
             passive: true,
           });
         });
src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.html (1)

14-14: Overly broad tracking scope on table click.

The tracking call fires on any click within the entire table, including clicks on individual cells, rows, and interactive elements. This may generate excessive tracking events and make it difficult to distinguish between different user actions within the table.

Consider tracking more specific interactions (e.g., row clicks, specific cell interactions) or moving this to individual interactive elements within the table.

src/app/app-modules/nurse-doctor/doctor-worklist/doctor-worklist.component.css (1)

99-102: Note: ::ng-deep is deprecated in Angular.

While ::ng-deep still works, it's officially deprecated. For component-specific styling that needs to pierce view encapsulation, consider using :host ::ng-deep or moving these styles to a global stylesheet if they're meant to be application-wide.

Regarding the static analysis hints flagging ::ng-deep as an unknown pseudo-element: this is a false positive, as Biome doesn't recognize Angular-specific pseudo-elements.

Alternative approach using :host
-::ng-deep .marker-h-r-c,
-::ng-deep .marker-h-r-c td {
+:host ::ng-deep .marker-h-r-c,
+:host ::ng-deep .marker-h-r-c td {
   color: #FF0000 !important;
 }

This scopes the styling to this component's view, providing better encapsulation.

src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/respiratory-system/respiratory-system.component.html (1)

12-214: Tracking integration looks good with a minor consideration.

The telemetry tracking is properly integrated across all form controls with appropriate event types for each control. The event selection is correct (selectionChange for dropdowns, focus for textareas, change for radio buttons).

Optional: Consider that focus events on textareas (lines 38, 77) may fire frequently if users navigate between fields. Ensure the tracking service implements debouncing or deduplication to avoid excessive telemetry data.

src/app/app-modules/nurse-doctor/shared/services/doctor.service.ts (1)

3018-3020: Verify the response type casting.

The responseType: 'blob' as 'json' casting may cause TypeScript type mismatches. Consider using responseType: 'blob' without the cast and updating the return type to Observable<Blob>.

🔎 Proposed fix
-  downloadSign(userID: any) {
-    return this.http.get(environment.downloadSignUrl + userID, {
-      responseType: 'blob' as 'json',
-    });
+  downloadSign(userID: any): Observable<Blob> {
+    return this.http.get(environment.downloadSignUrl + userID, {
+      responseType: 'blob',
+    }) as Observable<Blob>;
   }
src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/diagnosis.component.html (1)

14-14: Consider more granular event tracking for field interactions.

Using click events on component containers will fire for all child element clicks, potentially causing excessive or duplicate tracking events. For field interaction tracking, consider using focus, blur, or change events on individual form controls within each diagnosis component instead of a single click handler on the container.

Also applies to: 20-20, 26-26, 32-32, 38-38, 44-44

src/app/app-modules/nurse-doctor/history/general-opd-history/past-history/past-history.component.html (1)

51-52: LGTM with minor suggestion.

The tracking integration is implemented correctly. The multiple statements in template expressions (lines 51 and 186) work but consider extracting them to component methods for better readability and maintainability.

Optional refactor example

In the component TypeScript file, add:

onPastIllnessChange(value: any, index: number, pastIllness: any) {
  this.filterPastIllnessType(value, index, pastIllness);
  this.trackFieldInteraction('Past Illness');
}

Then update the template:

-(selectionChange)="filterPastIllnessType($event.value, i, pastIllness); trackFieldInteraction('Past Illness')"
+(selectionChange)="onPastIllnessChange($event.value, i, pastIllness)"

Also applies to: 186-187

src/app/app-modules/core/services/http-service.service.ts (1)

25-31: Add error handling for JSON.parse to prevent initialization failures.

If localStorage.getItem('appLanguage') returns corrupted JSON, JSON.parse will throw an exception and crash the service initialization. Consider wrapping this in a try-catch block with a fallback to null.

🔎 Proposed fix with error handling
  constructor(
    private _http: HttpClient,
    private http: HttpClient,
  ) {
    const storedLang = localStorage.getItem('appLanguage');
-   this.language = storedLang ? JSON.parse(storedLang) : null;
+   try {
+     this.language = storedLang ? JSON.parse(storedLang) : null;
+   } catch (error) {
+     console.error('Failed to parse language from localStorage:', error);
+     this.language = null;
+     localStorage.removeItem('appLanguage');
+   }

    this.appCurrentLanguge = new BehaviorSubject(this.language);
    this.currentLangugae$ = this.appCurrentLanguge.asObservable();
  }
src/app/app-modules/nurse-doctor/quick-consult/quick-consult.component.ts (1)

1492-1494: Consider user-facing error feedback

The error handler logs to console.error but doesn't provide user-facing feedback. Consider showing a dismissible notification or inline message so users know the search failed and can retry.

Suggested improvement
       error: () => {
         console.error('Error fetching diagnosis data');
+        this.confirmationService.alert(
+          this.currentLanguageSet?.alerts?.info?.errorFetchingDiagnosis || 'Error fetching diagnosis suggestions',
+          'error'
+        );
       },
src/app/app-modules/nurse-doctor/history/general-opd-history/family-history/family-history.component.html (1)

106-106: Remove extraneous blank line.

Line 106 contains an unnecessary blank line that should be removed for consistency.

🔎 Proposed fix
              (selectionChange)="trackFieldInteraction('Family Member')"
-              
            >
src/app/app-modules/nurse-doctor/history/general-opd-history/medication-history/medication-history.component.html (1)

102-102: Remove extraneous blank line.

Line 102 contains an unnecessary blank line that should be removed for consistency.

🔎 Proposed fix
            (click)="addMedicationHistory(); trackFieldInteraction('Add Medication')"
          >
            {{ currentLanguageSet?.common?.add }}
          </button>
-

          <button
src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-care-diagnosis/ncd-care-diagnosis.component.ts (1)

66-75: Pagination state variables are well-structured for per-index isolation.

The use of separate arrays (loadingMore, noMore, wantMore, pageByIndex, lastQueryByIndex) correctly isolates pagination state per diagnosis row, preventing cross-contamination between concurrent searches.

However, pageSize (line 67) is declared but never used in the implementation.

🔎 Remove unused variable
 private readonly PAGE_BASE = 0;
-pageSize: number | undefined = undefined;
src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/general-opd-diagnosis/general-opd-diagnosis.component.ts (1)

67-76: Unused pageSize property.

The pageSize property is declared but never assigned or referenced anywhere in the component. If it's intended for future use, consider removing it until needed to avoid dead code.

🔎 Suggested removal
  private readonly PAGE_BASE = 0;
-  pageSize: number | undefined = undefined;
-
  private readonly BOOTSTRAP_MAX_PAGES = 3; // when first page can't scroll, prefill up to this many extra pages
src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-screening-diagnosis/ncd-screening-diagnosis.component.ts (2)

101-110: Unused pageSize property (same as general-opd-diagnosis).

pageSize is declared but never used. Consider removing it to reduce dead code.


557-691: Consider extracting pagination logic to a shared utility.

The lazy-loading pagination logic (fetchPage, bootstrapUntilScrollable, onPanelReady, onAutoNearEnd, onDiagnosisInputKeyup) is duplicated across multiple diagnosis components. Extracting this to a shared base class, mixin, or service would reduce maintenance burden and ensure consistent behavior/fixes across all components.

This is a low-priority suggestion for future improvement.

src/app/app.component.ts (1)

20-22: Consider removing debug console.log.

The console.log('success') statement appears to be a debug artifact with no functional purpose.

🔎 Proposed cleanup
 ngOnInit() {
-  console.log('success');
 }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9add7a8 and bf728d1.

📒 Files selected for processing (98)
  • Common-UI
  • pom.xml
  • scripts/ci-prebuild.js
  • src/app/app-modules/core/components/app-footer/app-footer.component.html
  • src/app/app-modules/core/components/app-header/app-header.component.html
  • src/app/app-modules/core/components/app-header/app-header.component.ts
  • src/app/app-modules/core/components/beneficiary-details/beneficiary-details.component.html
  • src/app/app-modules/core/services/http-interceptor.service.ts
  • src/app/app-modules/core/services/http-service.service.ts
  • src/app/app-modules/lab/worklist/worklist.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/diagnosis.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/diagnosis.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/general-opd-diagnosis/general-opd-diagnosis.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/general-opd-diagnosis/general-opd-diagnosis.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-care-diagnosis/ncd-care-diagnosis.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-care-diagnosis/ncd-care-diagnosis.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-screening-diagnosis/ncd-screening-diagnosis.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-screening-diagnosis/ncd-screening-diagnosis.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/pnc-diagnosis/pnc-diagnosis.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/pnc-diagnosis/pnc-diagnosis.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/prescription/prescription.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/prescription/prescription.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/previous-significiant-findings/previous-significiant-findings.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/previous-significiant-findings/previous-significiant-findings.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/previous-visit-details/previous-visit-details.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/previous-visit-details/previous-visit-details.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/test-and-radiology/test-and-radiology.component.html
  • src/app/app-modules/nurse-doctor/case-sheet/general-case-sheet/doctor-diagnosis-case-sheet/doctor-diagnosis-case-sheet.component.ts
  • src/app/app-modules/nurse-doctor/doctor-worklist/doctor-worklist.component.css
  • src/app/app-modules/nurse-doctor/doctor-worklist/doctor-worklist.component.html
  • src/app/app-modules/nurse-doctor/doctor-worklist/doctor-worklist.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/general-examination/general-examination.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/general-examination/general-examination.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/head-to-toe-examination/head-to-toe-examination.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/head-to-toe-examination/head-to-toe-examination.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/cardio-vascular-system/cardio-vascular-system.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/cardio-vascular-system/cardio-vascular-system.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/central-nervous-system/central-nervous-system.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/central-nervous-system/central-nervous-system.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/genito-urinary-system/genito-urinary-system.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/genito-urinary-system/genito-urinary-system.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/musculoskeletal-system/musculoskeletal-system.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/musculoskeletal-system/musculoskeletal-system.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/obstetric-examination/obstetric-examination.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/obstetric-examination/obstetric-examination.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/respiratory-system/respiratory-system.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/respiratory-system/respiratory-system.component.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/comorbidity-concurrent-conditions/comorbidity-concurrent-conditions.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/comorbidity-concurrent-conditions/comorbidity-concurrent-conditions.component.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/family-history/family-history.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/family-history/family-history.component.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/medication-history/medication-history.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/medication-history/medication-history.component.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/menstrual-history/menstrual-history.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/menstrual-history/menstrual-history.component.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/past-history/past-history.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/past-history/past-history.component.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/past-obsteric-history/past-obsteric-history.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/past-obsteric-history/past-obsteric-history.component.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/personal-history/personal-history.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/personal-history/personal-history.component.ts
  • src/app/app-modules/nurse-doctor/nurse-doctor.module.ts
  • src/app/app-modules/nurse-doctor/nurse-worklist-wrapper/nurse-worklist/nurse-worklist.component.css
  • src/app/app-modules/nurse-doctor/nurse-worklist-wrapper/nurse-worklist/nurse-worklist.component.html
  • src/app/app-modules/nurse-doctor/nurse-worklist-wrapper/nurse-worklist/nurse-worklist.component.ts
  • src/app/app-modules/nurse-doctor/quick-consult/quick-consult.component.html
  • src/app/app-modules/nurse-doctor/quick-consult/quick-consult.component.ts
  • src/app/app-modules/nurse-doctor/refer/general-refer/general-refer.component.html
  • src/app/app-modules/nurse-doctor/refer/general-refer/general-refer.component.ts
  • src/app/app-modules/nurse-doctor/shared/services/doctor.service.ts
  • src/app/app-modules/nurse-doctor/shared/utility/autocomplete-scroller.directive.ts
  • src/app/app-modules/nurse-doctor/visit-details/chief-complaints/chief-complaints.component.html
  • src/app/app-modules/nurse-doctor/visit-details/chief-complaints/chief-complaints.component.ts
  • src/app/app-modules/nurse-doctor/visit-details/investigations/investigations.component.html
  • src/app/app-modules/nurse-doctor/visit-details/investigations/investigations.component.ts
  • src/app/app-modules/nurse-doctor/visit-details/upload-files/upload-files.component.html
  • src/app/app-modules/nurse-doctor/visit-details/upload-files/upload-files.component.ts
  • src/app/app-modules/nurse-doctor/visit-details/visit-details/visit-details.component.html
  • src/app/app-modules/nurse-doctor/visit-details/visit-details/visit-details.component.ts
  • src/app/app-modules/nurse-doctor/vitals/general-patient-vitals/general-patient-vitals.component.html
  • src/app/app-modules/nurse-doctor/vitals/general-patient-vitals/general-patient-vitals.component.ts
  • src/app/app-modules/pharmacist/worklist/worklist.component.ts
  • src/app/app-routing.module.ts
  • src/app/app.component.ts
  • src/app/app.module.ts
  • src/app/user-login/login/login.component.ts
  • src/assets/Assamese.json
  • src/assets/English.json
  • src/assets/Hindi.json
  • src/assets/Kannada.json
  • src/environments/environment.ci.ts.template
  • src/environments/environment.dev.ts
  • src/environments/environment.development.ts
  • src/environments/environment.local.ts
  • src/environments/environment.prod.ts
  • src/environments/environment.test.ts
🧰 Additional context used
🧠 Learnings (11)
📚 Learning: 2024-11-15T10:53:55.353Z
Learnt from: devikasuresh20
Repo: PSMRI/HWC-UI PR: 66
File: src/app/app-modules/nurse-doctor/visit-details/visit-details/visit-details.component.ts:368-393
Timestamp: 2024-11-15T10:53:55.353Z
Learning: In `src/app/app-modules/nurse-doctor/visit-details/visit-details/visit-details.component.ts`, when the user is focusing on resolving specific issues without undertaking broader refactoring of pre-existing code, avoid suggesting refactoring of existing methods like `getVisitDetails` and `getMMUVisitDetails`.

Applied to files:

  • src/app/app-modules/nurse-doctor/visit-details/upload-files/upload-files.component.ts
  • src/app/app-modules/nurse-doctor/doctor-worklist/doctor-worklist.component.css
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/cardio-vascular-system/cardio-vascular-system.component.html
  • src/app/app-modules/nurse-doctor/visit-details/chief-complaints/chief-complaints.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/comorbidity-concurrent-conditions/comorbidity-concurrent-conditions.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/prescription/prescription.component.html
  • src/app/app-modules/nurse-doctor/visit-details/upload-files/upload-files.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/prescription/prescription.component.ts
  • src/app/app-modules/pharmacist/worklist/worklist.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/previous-significiant-findings/previous-significiant-findings.component.html
  • src/app/app-modules/nurse-doctor/vitals/general-patient-vitals/general-patient-vitals.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/previous-significiant-findings/previous-significiant-findings.component.ts
  • src/app/app-modules/nurse-doctor/quick-consult/quick-consult.component.html
  • src/app/app-modules/nurse-doctor/doctor-worklist/doctor-worklist.component.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/family-history/family-history.component.html
  • src/app/app-modules/nurse-doctor/visit-details/chief-complaints/chief-complaints.component.ts
  • src/app/app-modules/lab/worklist/worklist.component.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/medication-history/medication-history.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/respiratory-system/respiratory-system.component.ts
  • src/app/app-modules/nurse-doctor/vitals/general-patient-vitals/general-patient-vitals.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/genito-urinary-system/genito-urinary-system.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/musculoskeletal-system/musculoskeletal-system.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.ts
  • src/app/app-modules/nurse-doctor/nurse-worklist-wrapper/nurse-worklist/nurse-worklist.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/musculoskeletal-system/musculoskeletal-system.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/genito-urinary-system/genito-urinary-system.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/previous-visit-details/previous-visit-details.component.ts
  • src/app/app-modules/nurse-doctor/quick-consult/quick-consult.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/obstetric-examination/obstetric-examination.component.ts
  • src/app/app-modules/nurse-doctor/nurse-worklist-wrapper/nurse-worklist/nurse-worklist.component.css
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.html
  • src/app/app-modules/nurse-doctor/doctor-worklist/doctor-worklist.component.html
  • src/app/app-modules/nurse-doctor/shared/services/doctor.service.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/past-obsteric-history/past-obsteric-history.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/pnc-diagnosis/pnc-diagnosis.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/central-nervous-system/central-nervous-system.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/personal-history/personal-history.component.ts
  • src/app/app-modules/nurse-doctor/visit-details/visit-details/visit-details.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/cardio-vascular-system/cardio-vascular-system.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/general-examination/general-examination.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/past-obsteric-history/past-obsteric-history.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/central-nervous-system/central-nervous-system.component.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/personal-history/personal-history.component.html
  • src/app/app-modules/nurse-doctor/visit-details/investigations/investigations.component.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/past-history/past-history.component.ts
  • src/app/app-modules/nurse-doctor/refer/general-refer/general-refer.component.html
  • src/app/app-modules/nurse-doctor/visit-details/visit-details/visit-details.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/head-to-toe-examination/head-to-toe-examination.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/test-and-radiology/test-and-radiology.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-screening-diagnosis/ncd-screening-diagnosis.component.html
  • src/app/app-modules/nurse-doctor/case-sheet/general-case-sheet/doctor-diagnosis-case-sheet/doctor-diagnosis-case-sheet.component.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/medication-history/medication-history.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/general-examination/general-examination.component.ts
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/respiratory-system/respiratory-system.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/systemic-examination/obstetric-examination/obstetric-examination.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/family-history/family-history.component.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/past-history/past-history.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/comorbidity-concurrent-conditions/comorbidity-concurrent-conditions.component.ts
  • src/app/app-modules/nurse-doctor/nurse-doctor.module.ts
  • src/app/app-modules/nurse-doctor/nurse-worklist-wrapper/nurse-worklist/nurse-worklist.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/previous-visit-details/previous-visit-details.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-care-diagnosis/ncd-care-diagnosis.component.html
  • src/app/app-modules/nurse-doctor/visit-details/investigations/investigations.component.html
  • src/app/app-modules/nurse-doctor/examination/general-opd-examination/head-to-toe-examination/head-to-toe-examination.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-care-diagnosis/ncd-care-diagnosis.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/diagnosis.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/ncd-screening-diagnosis/ncd-screening-diagnosis.component.ts
  • src/app/app-modules/nurse-doctor/history/general-opd-history/menstrual-history/menstrual-history.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/diagnosis.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/general-opd-diagnosis/general-opd-diagnosis.component.html
  • src/app/app-modules/nurse-doctor/refer/general-refer/general-refer.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/general-opd-diagnosis/general-opd-diagnosis.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/pnc-diagnosis/pnc-diagnosis.component.ts
📚 Learning: 2025-06-02T11:55:35.377Z
Learnt from: devikasuresh20
Repo: PSMRI/HWC-UI PR: 122
File: src/app/app-modules/core/components/open-previous-visit-details/open-previous-visit-details.component.html:100-105
Timestamp: 2025-06-02T11:55:35.377Z
Learning: The HWC-UI codebase uses nested `<tr>` elements within `<td>` elements as part of the existing implementation pattern across multiple components in files like `src/app/app-modules/core/components/open-previous-visit-details/open-previous-visit-details.component.html`. Refactoring this HTML table structure would require changes across multiple components and should be considered as a separate, larger refactoring effort.

Applied to files:

  • src/app/app-modules/nurse-doctor/doctor-worklist/doctor-worklist.component.css
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/previous-significiant-findings/previous-significiant-findings.component.html
  • src/app/app-modules/nurse-doctor/nurse-worklist-wrapper/nurse-worklist/nurse-worklist.component.css
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.html
  • src/app/app-modules/nurse-doctor/doctor-worklist/doctor-worklist.component.html
  • src/app/app-modules/nurse-doctor/visit-details/visit-details/visit-details.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/past-obsteric-history/past-obsteric-history.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/personal-history/personal-history.component.html
  • src/app/app-modules/nurse-doctor/refer/general-refer/general-refer.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/test-and-radiology/test-and-radiology.component.html
  • src/app/app-modules/nurse-doctor/history/general-opd-history/past-history/past-history.component.html
  • src/app/app-modules/nurse-doctor/nurse-worklist-wrapper/nurse-worklist/nurse-worklist.component.html
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/previous-visit-details/previous-visit-details.component.html
  • src/app/app-modules/core/components/beneficiary-details/beneficiary-details.component.html
  • src/app/app-modules/core/components/app-footer/app-footer.component.html
📚 Learning: 2024-11-15T10:51:41.609Z
Learnt from: devikasuresh20
Repo: PSMRI/HWC-UI PR: 66
File: src/app/app-modules/nurse-doctor/visit-details/visit-details/visit-details.component.ts:278-307
Timestamp: 2024-11-15T10:51:41.609Z
Learning: In the `HWC-UI` project, when accessing nested properties of `value.data`, such as `value.data.NCDCareNurseVisitDetail.fileIDs` in `visit-details.component.ts`, the properties are guaranteed to exist, and null checks are already added for `value.data`. Therefore, additional null checks for nested properties are not necessary.

Applied to files:

  • src/app/app-modules/nurse-doctor/visit-details/upload-files/upload-files.component.html
  • src/app/app-modules/nurse-doctor/nurse-worklist-wrapper/nurse-worklist/nurse-worklist.component.ts
  • src/app/app-modules/nurse-doctor/visit-details/visit-details/visit-details.component.html
📚 Learning: 2024-11-13T11:08:50.964Z
Learnt from: helenKaryamsetty
Repo: PSMRI/HWC-UI PR: 50
File: src/app/app-modules/nurse-doctor/workarea/workarea.component.ts:4219-4228
Timestamp: 2024-11-13T11:08:50.964Z
Learning: In the function `getMappedAbdmFacility()` in `src/app/app-modules/nurse-doctor/workarea/workarea.component.ts`, the `loginDataResponse` retrieved from `localStorage` is guaranteed to be available and properly formatted; therefore, null checks and error handling for this data are unnecessary.

Applied to files:

  • src/app/app-modules/pharmacist/worklist/worklist.component.ts
  • src/app/app-modules/nurse-doctor/doctor-worklist/doctor-worklist.component.ts
  • src/app/app-modules/lab/worklist/worklist.component.ts
  • src/app/app-modules/nurse-doctor/nurse-worklist-wrapper/nurse-worklist/nurse-worklist.component.ts
  • src/app/app-modules/nurse-doctor/case-sheet/general-case-sheet/doctor-diagnosis-case-sheet/doctor-diagnosis-case-sheet.component.ts
  • src/app/user-login/login/login.component.ts
  • src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/pnc-diagnosis/pnc-diagnosis.component.ts
📚 Learning: 2024-10-28T12:29:22.526Z
Learnt from: devikasuresh20
Repo: PSMRI/HWC-UI PR: 61
File: src/assets/Hindi.json:2090-2090
Timestamp: 2024-10-28T12:29:22.526Z
Learning: For the `Hindi.json` translation file, when adding new messages and the Hindi translation is not yet available, it's acceptable to temporarily leave the message in English and update it later when the translation is provided by PSMRI.

Applied to files:

  • src/assets/Hindi.json
📚 Learning: 2025-06-03T06:55:03.688Z
Learnt from: 5Amogh
Repo: PSMRI/HWC-UI PR: 123
File: src/app/user-login/captcha-service/captcha.service.ts:15-15
Timestamp: 2025-06-03T06:55:03.688Z
Learning: In the PSMRI/HWC-UI project, empty environment variable values like captchaChallengeURL are intentional as proper values are provided by the development team before the application runs as part of their deployment process.

Applied to files:

  • src/environments/environment.ci.ts.template
  • src/environments/environment.local.ts
  • src/environments/environment.dev.ts
  • src/environments/environment.development.ts
  • src/environments/environment.prod.ts
📚 Learning: 2024-12-12T10:56:30.617Z
Learnt from: helenKaryamsetty
Repo: PSMRI/HWC-UI PR: 77
File: src/environments/environment.development.ts:48-48
Timestamp: 2024-12-12T10:56:30.617Z
Learning: In the project, the `abhaExtension` variable is set to `sbx` in `environment.development.ts` and `environment.test.ts` for development and test environments, while it is set to `abdm` in `environment.prod.ts` for the production environment.

Applied to files:

  • src/environments/environment.ci.ts.template
  • src/environments/environment.dev.ts
  • src/environments/environment.development.ts
  • src/environments/environment.prod.ts
📚 Learning: 2025-06-30T11:22:52.940Z
Learnt from: devikasuresh20
Repo: PSMRI/HWC-UI PR: 144
File: src/app/user-login/service/service.component.ts:185-187
Timestamp: 2025-06-30T11:22:52.940Z
Learning: In src/app/user-login/service/service.component.ts, the loginData retrieved from session storage in the getServicePointAsync method is guaranteed to be available before this flow executes, so null checks before JSON.parse are unnecessary.

Applied to files:

  • src/app/app-modules/core/services/http-service.service.ts
  • src/app/user-login/login/login.component.ts
📚 Learning: 2024-10-28T12:30:24.342Z
Learnt from: devikasuresh20
Repo: PSMRI/HWC-UI PR: 61
File: src/assets/English.json:2094-2094
Timestamp: 2024-10-28T12:30:24.342Z
Learning: In the `src/assets/English.json` file, duplicate translation keys are intentionally kept because they are used in multiple components.

Applied to files:

  • src/assets/English.json
📚 Learning: 2025-06-03T06:54:14.135Z
Learnt from: 5Amogh
Repo: PSMRI/HWC-UI PR: 123
File: src/app/user-login/login/login.component.ts:55-55
Timestamp: 2025-06-03T06:54:14.135Z
Learning: In src/app/user-login/login/login.component.ts, the captchaToken property uses definite assignment assertion (!) without explicit initialization, but this is safe because the login button is disabled until the CAPTCHA is successfully resolved, ensuring the property is always defined when accessed in the login method.

Applied to files:

  • src/app/user-login/login/login.component.ts
📚 Learning: 2025-06-03T06:52:56.725Z
Learnt from: 5Amogh
Repo: PSMRI/HWC-UI PR: 123
File: src/app/user-login/login/login.component.ts:349-351
Timestamp: 2025-06-03T06:52:56.725Z
Learning: In src/app/user-login/login/login.component.ts, the onCaptchaResolved method parameter uses `any` type instead of `string` because the Cloudflare Turnstile CAPTCHA library's resolution function emits events that don't statically define the return type as string, and using `string` type causes HTML template compilation errors.

Applied to files:

  • src/app/user-login/login/login.component.ts
🧬 Code graph analysis (3)
src/app/app-modules/nurse-doctor/doctor-worklist/doctor-worklist.component.ts (5)
src/environments/environment.dev.ts (1)
  • environment (70-573)
src/environments/environment.development.ts (1)
  • environment (71-575)
src/environments/environment.local.ts (1)
  • environment (71-574)
src/environments/environment.prod.ts (1)
  • environment (71-575)
src/environments/environment.test.ts (1)
  • environment (69-570)
src/app/app-modules/nurse-doctor/shared/services/doctor.service.ts (4)
src/environments/environment.dev.ts (1)
  • environment (70-573)
src/environments/environment.local.ts (1)
  • environment (71-574)
src/environments/environment.prod.ts (1)
  • environment (71-575)
src/environments/environment.test.ts (1)
  • environment (69-570)
src/environments/environment.local.ts (3)
src/environments/environment.dev.ts (1)
  • environment (70-573)
src/environments/environment.development.ts (1)
  • environment (71-575)
src/environments/environment.test.ts (1)
  • environment (69-570)
🪛 Biome (2.1.2)
src/app/app-modules/nurse-doctor/doctor-worklist/doctor-worklist.component.css

[error] 99-99: Unexpected unknown pseudo-elements: ng-deep

See MDN web docs for more details.
Use a known pseudo-elements instead, such as:

(lint/correctness/noUnknownPseudoElement)


[error] 100-100: Unexpected unknown pseudo-elements: ng-deep

See MDN web docs for more details.
Use a known pseudo-elements instead, such as:

(lint/correctness/noUnknownPseudoElement)

🪛 GitHub Check: lint-and-audit / lint-and-audit
src/app/app-modules/nurse-doctor/shared/utility/autocomplete-scroller.directive.ts

[warning] 67-67:
Forbidden non-null assertion

<footer class="footer container-fluid">
<div class="row">
<div class="col-4 text-left">
<div class="col-3 text-left">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Initial exploration: check repo structure and locate key files

# List the repository structure
echo "=== Repository structure ==="
git ls-files | head -30

echo -e "\n=== Looking for routing files ==="
fd -e ts -e js | grep -i route | head -20

echo -e "\n=== Looking for translation files ==="
fd -e json | grep -i "lang\|i18n\|translation" | head -20

Repository: PSMRI/HWC-UI

Length of output: 1011


🏁 Script executed:

#!/bin/bash
# Description: Verify feedback route exists and language key is defined

echo "=== Checking for feedback route in routing modules ==="
rg -n "path.*['\"]feedback['\"]" --type=ts

echo -e "\n=== Checking for platform_feedback language key ==="
rg -n "platform_feedback" --type=json -g "*.json"

Repository: PSMRI/HWC-UI

Length of output: 381


🏁 Script executed:

#!/bin/bash
# Check the footer component to see the actual changes
echo "=== Content of app-footer.component.html ==="
cat -n "src/app/app-modules/core/components/app-footer/app-footer.component.html"

Repository: PSMRI/HWC-UI

Length of output: 2827


🏁 Script executed:

#!/bin/bash
# Find all language JSON files and check for platform_feedback key

echo "=== All language JSON files ==="
fd -e json | grep -i "lang\|\.json$" | sort

echo -e "\n=== Checking all JSON files for platform_feedback ==="
for file in src/assets/*.json; do
  if [ -f "$file" ]; then
    count=$(grep -c "platform_feedback" "$file" 2>/dev/null || echo "0")
    echo "$file: platform_feedback found = $count"
  fi
done

echo -e "\n=== Sample structure from English.json ==="
rg -A 3 '"platform_feedback"' "src/assets/English.json"

Repository: PSMRI/HWC-UI

Length of output: 1010


🏁 Script executed:

#!/bin/bash
# Verify the routing module contains the feedback route configuration

echo "=== Feedback route configuration in routing module ==="
rg -B 2 -A 5 'path.*feedback' src/app/app-routing.module.ts

Repository: PSMRI/HWC-UI

Length of output: 273


Add missing platform_feedback translation to Kannada.json.

The footer feedback link has been successfully configured with the correct route, query parameter, and language keys—except that src/assets/Kannada.json is missing the platform_feedback object entirely. English, Hindi, and Assamese translation files all contain it, but Kannada users will fall back to the hardcoded "Feedback" string. Add the missing translation key to Kannada.json to maintain consistency across all supported languages.

🤖 Prompt for AI Agents
In @src/app/app-modules/core/components/app-footer/app-footer.component.html at
line 3, Add the missing "platform_feedback" translation object into Kannada.json
so the footer feedback link uses localized text; replicate the same keys used in
other locale files (e.g., "title" and any subkeys used for the feedback link)
under the "platform_feedback" key in Kannada.json with appropriate Kannada
strings so it matches English/Hindi/Assamese structure.

Comment on lines +23 to +52
<ng-container *ngIf="beneficiary?.fatherName">
<tr style="font-size: 14px; color: #000000">
<th id="fatherName">
{{ current_language_set?.bendetails?.fatherName }}:
</th>
</tr>
<tr style="color: #595959; font-size: 14px">
<td>{{ beneficiary?.fatherName }}</td>
</tr>
</ng-container>
<ng-container *ngIf="beneficiary?.lastName">
<tr style="font-size: 14px; color: #000000">
<th id="lastName">
{{ current_language_set?.bendetails?.lastName }}:
</th>
</tr>
<tr style="color: #595959; font-size: 14px">
<td>{{ beneficiary?.lastName }}</td>
</tr>
</ng-container>
<ng-container *ngIf="beneficiary?.preferredPhoneNum">
<tr style="font-size: 14px; color: #000000">
<th id="phoneNo">
{{ current_language_set?.bendetails?.phoneNo }}:
</th>
</tr>
<tr style="color: #595959; font-size: 14px">
<td>{{ beneficiary?.preferredPhoneNum }}</td>
</tr>
</ng-container>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Inconsistent field display between flow status blocks.

These three new fields (fatherName, lastName, preferredPhoneNum) are only displayed when benFlowStatus is true (lines 23-52), but are missing from the second table block when benFlowStatus is false (lines 131-231). This creates an inconsistent user experience where different information is shown based on the flow status.

🔎 Verify and align the second block

Add the same three conditional sections to the second table block (after line 151) to ensure consistent display of beneficiary information regardless of flow status:

       <tr style="color: #595959; font-size: 14px">
         <td>{{ beneficiaryName | titlecase }}</td>
       </tr>
+      <ng-container *ngIf="beneficiary?.fatherName">
+        <tr style="font-size: 14px; color: #000000">
+          <th id="fatherName">
+            {{ current_language_set?.bendetails?.fatherName }}:
+          </th>
+        </tr>
+        <tr style="color: #595959; font-size: 14px">
+          <td>{{ beneficiary?.fatherName }}</td>
+        </tr>
+      </ng-container>
+      <ng-container *ngIf="beneficiary?.lastName">
+        <tr style="font-size: 14px; color: #000000">
+          <th id="lastName">
+            {{ current_language_set?.bendetails?.lastName }}:
+          </th>
+        </tr>
+        <tr style="color: #595959; font-size: 14px">
+          <td>{{ beneficiary?.lastName }}</td>
+        </tr>
+      </ng-container>
+      <ng-container *ngIf="beneficiary?.preferredPhoneNum">
+        <tr style="font-size: 14px; color: #000000">
+          <th id="phoneNo">
+            {{ current_language_set?.bendetails?.phoneNo }}:
+          </th>
+        </tr>
+        <tr style="color: #595959; font-size: 14px">
+          <td>{{ beneficiary?.preferredPhoneNum }}</td>
+        </tr>
+      </ng-container>

       <tr style="font-size: 14px; color: #000000">
         <th id="beneficiaryName">{{ current_language_set?.familyId }}:</th>
       </tr>

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In
@src/app/app-modules/core/components/beneficiary-details/beneficiary-details.component.html
around lines 23 - 52, The three conditional display sections for
beneficiary?.fatherName, beneficiary?.lastName and
beneficiary?.preferredPhoneNum that use current_language_set?.bendetails labels
are only present in the benFlowStatus=true table; add the same three
<ng-container *ngIf="..."> blocks (using the same ids: fatherName, lastName,
phoneNo and the same label lookups current_language_set?.bendetails?.fatherName
/ ?.lastName / ?.phoneNo) into the alternate table block that renders when
benFlowStatus is false so both flow branches show the same fields consistently.

Comment on lines +90 to 113
if (error.status === 401) {
this.handleSessionExpiry(
this.currentLanguageSet.sessionExpiredPleaseLogin ||
'Session has expired, please login again.',
);
} else if (error.status === 403) {
this.handleSessionExpiry(
this.currentLanguageSet.accessDenied ||
'Access Denied. You do not have permission to access this resource.',
);
} else if (error.status === 500) {
this.handleSessionExpiry(
this.currentLanguageSet.internaleServerError,
);
} else {
this.handleSessionExpiry(
error.message ||
this.currentLanguageSet.somethingWentWrong ||
'Something went wrong. Please try again later.',
);
}
sessionStorage.clear();
this.sessionstorage.clear();
return throwError(error.error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Session clearing on all HTTP errors is overly aggressive.

The current implementation clears session storage on any HTTP error (lines 111-112), including transient errors like 404 or 503. This could unexpectedly log users out due to temporary network issues or non-critical API failures.

Additionally, line 102 uses this.currentLanguageSet.internaleServerError without a fallback, unlike other error handlers. Note the potential typo in internaleServerError (missing 'n' in "internal").

🔎 Suggested fix
       } else if (error.status === 500) {
         this.handleSessionExpiry(
-          this.currentLanguageSet.internaleServerError,
+          this.currentLanguageSet.internalServerError ||
+            'Internal server error. Please try again later.',
         );
       } else {
-        this.handleSessionExpiry(
-          error.message ||
-            this.currentLanguageSet.somethingWentWrong ||
-            'Something went wrong. Please try again later.',
-        );
+        // Only clear session for auth-related errors (401, 403)
+        // For other errors, show message without session termination
+        this.confirmationService.alert(
+          error.message ||
+            this.currentLanguageSet.somethingWentWrong ||
+            'Something went wrong. Please try again later.',
+          'error',
+        );
+        return throwError(error.error);
       }
       sessionStorage.clear();
       this.sessionstorage.clear();

Consider moving session clearing inside the specific 401/403 handlers rather than applying it universally.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In @src/app/app-modules/core/services/http-interceptor.service.ts around lines
90 - 113, The code currently clears sessionStorage on every HTTP error; instead,
remove the unconditional sessionStorage.clear() and this.sessionstorage.clear()
calls and call them only inside the 401 and 403 branches where you invoke
handleSessionExpiry (i.e., after the handleSessionExpiry call in the blocks
handling error.status === 401 and error.status === 403) so users aren’t logged
out on transient errors; also change usage of
this.currentLanguageSet.internaleServerError to a correct key (fix the typo to
internalServerError) and provide a fallback string like
this.currentLanguageSet.internalServerError || 'Internal server error. Please
try again later.' so the 500 branch behaves like the others.

import { FormGroup } from '@angular/forms';
import { HttpServiceService } from 'src/app/app-modules/core/services/http-service.service';
import { SetLanguageComponent } from 'src/app/app-modules/core/components/set-language.component';
import { AmritTrackingService } from 'Common-UI/src/tracking';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify the import path is properly configured

# Check tsconfig.json for path mappings
if [ -f tsconfig.json ]; then
  echo "=== tsconfig.json path mappings ==="
  cat tsconfig.json | jq '.compilerOptions.paths' 2>/dev/null || cat tsconfig.json | grep -A 20 '"paths"'
fi

# Check if the source file exists
echo -e "\n=== Searching for tracking module ==="
fd -t f "tracking\.(ts|js)$" 2>/dev/null | head -20

# Check package.json for Common-UI dependency
if [ -f package.json ]; then
  echo -e "\n=== Checking package.json for Common-UI ==="
  cat package.json | jq '.dependencies["Common-UI"], .devDependencies["Common-UI"]' 2>/dev/null || grep -i "common-ui" package.json
fi

# Also check for Common-UI directory
echo -e "\n=== Searching for Common-UI directory ==="
fd -t d "Common-UI" 2>/dev/null | head -10

Repository: PSMRI/HWC-UI

Length of output: 239


🏁 Script executed:

#!/bin/bash

# Check the structure of Common-UI
echo "=== Common-UI directory structure ==="
ls -la Common-UI/ 2>/dev/null | head -20

# Look for tracking module in Common-UI
echo -e "\n=== Searching for tracking in Common-UI ==="
find Common-UI -name "*tracking*" -type f 2>/dev/null | head -20

# Read tsconfig.json directly
echo -e "\n=== Full tsconfig.json content ==="
cat tsconfig.json | head -80

# Check for any typescript configuration files
echo -e "\n=== Looking for tsconfig variations ==="
find . -maxdepth 2 -name "tsconfig*.json" -type f 2>/dev/null

Repository: PSMRI/HWC-UI

Length of output: 1365


🏁 Script executed:

#!/bin/bash

# Check tsconfig.app.json
echo "=== tsconfig.app.json content ==="
cat tsconfig.app.json

# Check for webpack or other build configs
echo -e "\n=== Build configuration files ==="
ls -la | grep -E "(webpack|angular\.json|build)"

# Check angular.json for path configurations
if [ -f angular.json ]; then
  echo -e "\n=== angular.json (first 100 lines) ==="
  cat angular.json | head -100
fi

Repository: PSMRI/HWC-UI

Length of output: 3655


🏁 Script executed:

#!/bin/bash

# Search for other imports from Common-UI
echo "=== All imports from Common-UI ==="
rg "from ['\"]Common-UI" --type ts --type tsx -A 0 -B 0 | head -50

# Count how many files use Common-UI imports
echo -e "\n=== Count of files with Common-UI imports ==="
rg "from ['\"]Common-UI" --type ts --type tsx -l | wc -l

# Check if there's a package.json in Common-UI
echo -e "\n=== Check Common-UI for package.json or index files ==="
ls -la Common-UI/ || echo "Empty directory confirmed"
find . -path "./Common-UI*" -type f 2>/dev/null | head -20

Repository: PSMRI/HWC-UI

Length of output: 380


Fix the broken import path for AmritTrackingService.

The import 'Common-UI/src/tracking' cannot be resolved. The Common-UI directory is empty, no path alias is configured in TypeScript, and this is the only import from Common-UI in the codebase. Either correct the import path to reference an existing module, or ensure the Common-UI module is properly set up with the tracking module.

🤖 Prompt for AI Agents
In
@src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/diagnosis.component.ts
at line 26, The import for AmritTrackingService is unresolved; update the import
in the DiagnosisComponent (where AmritTrackingService is referenced) to point to
the actual module that exports it (replace 'Common-UI/src/tracking' with the
correct package/path that contains AmritTrackingService), or if Common-UI should
be a dependency, add/restore the Common-UI package and its tracking export and
update tsconfig paths accordingly; ensure the symbol AmritTrackingService is
exported from the target module and update any usages in the component to match
the corrected import.

Comment on lines +401 to +412
},
error: () => {
console.error('Error fetching diagnosis data');
},
complete: () => {
const wantChain = this.wantMore[index] && !this.noMore[index];
this.loadingMore[index] = false;
this.wantMore[index] = false;

if (wantChain) this.fetchPage(index, true);
},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

loadingMore flag not reset on error, blocking future fetches.

When fetchPage encounters an error, loadingMore[index] remains true because the complete callback doesn't execute after an error. This permanently blocks pagination for that index until the component is recreated.

🔎 Proposed fix to reset state on error
        error: () => {
          console.error('Error fetching diagnosis data');
+         this.loadingMore[index] = false;
+         this.wantMore[index] = false;
        },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
},
error: () => {
console.error('Error fetching diagnosis data');
},
complete: () => {
const wantChain = this.wantMore[index] && !this.noMore[index];
this.loadingMore[index] = false;
this.wantMore[index] = false;
if (wantChain) this.fetchPage(index, true);
},
});
},
error: () => {
console.error('Error fetching diagnosis data');
this.loadingMore[index] = false;
this.wantMore[index] = false;
},
complete: () => {
const wantChain = this.wantMore[index] && !this.noMore[index];
this.loadingMore[index] = false;
this.wantMore[index] = false;
if (wantChain) this.fetchPage(index, true);
},
});
🤖 Prompt for AI Agents
In
@src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/general-opd-diagnosis/general-opd-diagnosis.component.ts
around lines 401 - 412, The error handler currently leaves loadingMore[index]
set to true and blocks further pagination; update the error callback inside the
subscription in general-opd-diagnosis.component.ts to (1) accept the error
param, (2) log the actual error (e.g., console.error('Error fetching diagnosis
data', err)), and (3) reset loadingMore[index] = false and wantMore[index] =
false so the index is not permanently blocked; keep noMore[index] untouched and
do not call fetchPage there (the complete path handles chaining).

Comment on lines +553 to +598
private fetchPage(
type: 'provisional' | 'confirmatory',
index: number,
append = false,
) {
const s = this.state[type];
const term = s.lastQueryByIndex[index];
if (!term) return;

const nextLogical = (s.pageByIndex[index] ?? 0) + (append ? 1 : 0);
const pageAtReq = nextLogical + this.PAGE_BASE;
if (s.loadingMore[index]) return;
s.loadingMore[index] = true;

this.masterdataService
.searchDiagnosisBasedOnPageNo(term, pageAtReq)
.subscribe({
next: (results: any) => {
if (s.lastQueryByIndex[index] !== term) return;
const list = results?.data?.sctMaster ?? [];
if (append) {
const existing = new Set(
(s.suggested[index] ?? []).map(
(d: any) => d.id ?? d.code ?? d.term,
),
);
s.suggested[index] = [
...(s.suggested[index] ?? []),
...list.filter(
(d: any) => !existing.has(d.id ?? d.code ?? d.term),
),
];
} else {
s.suggested[index] = list;
}
s.pageByIndex[index] = nextLogical;
if (!list.length) s.noMore[index] = true;
},
complete: () => {
const wantChain = s.wantMore[index] && !s.noMore[index];
s.loadingMore[index] = false;
s.wantMore[index] = false;
if (wantChain) this.fetchPage(type, index, true);
},
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add error handling and prevent memory leaks.

The fetchPage method has two issues:

  1. No error handler for the subscription - network failures will go unhandled
  2. No cleanup/unsubscribe mechanism - could cause memory leaks if the component is destroyed while requests are pending
🔎 Proposed fix
+  private subscriptions: Subscription[] = [];
+
   private fetchPage(
     type: 'provisional' | 'confirmatory',
     index: number,
     append = false,
   ) {
     const s = this.state[type];
     const term = s.lastQueryByIndex[index];
     if (!term) return;

     const nextLogical = (s.pageByIndex[index] ?? 0) + (append ? 1 : 0);
     const pageAtReq = nextLogical + this.PAGE_BASE;
     if (s.loadingMore[index]) return;
     s.loadingMore[index] = true;

-    this.masterdataService
+    const sub = this.masterdataService
       .searchDiagnosisBasedOnPageNo(term, pageAtReq)
       .subscribe({
         next: (results: any) => {
           if (s.lastQueryByIndex[index] !== term) return;
           const list = results?.data?.sctMaster ?? [];
           if (append) {
             const existing = new Set(
               (s.suggested[index] ?? []).map(
                 (d: any) => d.id ?? d.code ?? d.term,
               ),
             );
             s.suggested[index] = [
               ...(s.suggested[index] ?? []),
               ...list.filter(
                 (d: any) => !existing.has(d.id ?? d.code ?? d.term),
               ),
             ];
           } else {
             s.suggested[index] = list;
           }
           s.pageByIndex[index] = nextLogical;
           if (!list.length) s.noMore[index] = true;
         },
+        error: (err) => {
+          console.error('Error fetching diagnosis suggestions:', err);
+          s.loadingMore[index] = false;
+          s.wantMore[index] = false;
+        },
         complete: () => {
           const wantChain = s.wantMore[index] && !s.noMore[index];
           s.loadingMore[index] = false;
           s.wantMore[index] = false;
           if (wantChain) this.fetchPage(type, index, true);
         },
       });
+    this.subscriptions.push(sub);
   }

Then update ngOnDestroy:

   ngOnDestroy() {
     if (this.beneficiaryDetailsSubscription)
       this.beneficiaryDetailsSubscription.unsubscribe();
     if (this.diagnosisSubscription) {
       this.diagnosisSubscription.unsubscribe();
     }
+    this.subscriptions.forEach(sub => sub.unsubscribe());
   }

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In
@src/app/app-modules/nurse-doctor/case-record/general-case-record/diagnosis/pnc-diagnosis/pnc-diagnosis.component.ts
around lines 553 - 598, The fetchPage method lacks error handling and cleanup:
add an error handler to the Observable.subscribe call to log/set state on
network errors (update the subscribe call in fetchPage to include an error:
(err) => { s.loadingMore[index]=false; s.wantMore[index]=false;
s.noMore[index]=true/false as appropriate; and log or surface the error } ), and
prevent leaks by tying the request lifecycle to the component destruction—either
store the returned Subscription from subscribe and unsubscribe it in
ngOnDestroy, or (preferred) introduce a private destroy$ = new Subject<void>()
on the component and replace .subscribe(...) with
.pipe(takeUntil(this.destroy$)).subscribe({...}) and then in ngOnDestroy call
this.destroy$.next(); this.destroy$.complete(); so any in-flight fetchPage
requests are cancelled when the component is destroyed.

Comment on lines +119 to +121
redirectToCHOReport() {
window.location.href = `${environment.dhisURL}${JSON.parse(this.sessionstorage.getItem('loginDataResponse'))?.dhistoken}`;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add error handling and validation for CHO report redirection.

The method has several robustness concerns:

  1. JSON.parse() will throw if loginDataResponse is null or contains invalid JSON
  2. No validation that environment.dhisURL is configured (empty string would result in invalid URL)
  3. No validation that dhistoken exists before string interpolation
  4. Immediate navigation without user confirmation or error feedback
🔎 Proposed fix with error handling
  redirectToCHOReport() {
-    window.location.href = `${environment.dhisURL}${JSON.parse(this.sessionstorage.getItem('loginDataResponse'))?.dhistoken}`;
+    try {
+      if (!environment.dhisURL) {
+        this.confirmationService.alert('CHO report URL is not configured', 'error');
+        return;
+      }
+      
+      const loginDataResponse = this.sessionstorage.getItem('loginDataResponse');
+      if (!loginDataResponse) {
+        this.confirmationService.alert('Login data not found', 'error');
+        return;
+      }
+      
+      const loginData = JSON.parse(loginDataResponse);
+      if (!loginData?.dhistoken) {
+        this.confirmationService.alert('DHIS token not found', 'error');
+        return;
+      }
+      
+      window.location.href = `${environment.dhisURL}${loginData.dhistoken}`;
+    } catch (error) {
+      this.confirmationService.alert('Failed to navigate to CHO report', 'error');
+      console.error('Error in redirectToCHOReport:', error);
+    }
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
redirectToCHOReport() {
window.location.href = `${environment.dhisURL}${JSON.parse(this.sessionstorage.getItem('loginDataResponse'))?.dhistoken}`;
}
redirectToCHOReport() {
try {
if (!environment.dhisURL) {
this.confirmationService.alert('CHO report URL is not configured', 'error');
return;
}
const loginDataResponse = this.sessionstorage.getItem('loginDataResponse');
if (!loginDataResponse) {
this.confirmationService.alert('Login data not found', 'error');
return;
}
const loginData = JSON.parse(loginDataResponse);
if (!loginData?.dhistoken) {
this.confirmationService.alert('DHIS token not found', 'error');
return;
}
window.location.href = `${environment.dhisURL}${loginData.dhistoken}`;
} catch (error) {
this.confirmationService.alert('Failed to navigate to CHO report', 'error');
console.error('Error in redirectToCHOReport:', error);
}
}
🤖 Prompt for AI Agents
In
@src/app/app-modules/nurse-doctor/doctor-worklist/doctor-worklist.component.ts
around lines 119 - 121, In redirectToCHOReport, add robust validation and error
handling: wrap JSON.parse(this.sessionstorage.getItem('loginDataResponse')) in a
try/catch and handle a null/invalid value; verify environment.dhisURL is a
non-empty string and that the parsed object contains a non-empty dhistoken
before building the URL; if checks fail, emit a user-facing error (e.g., show a
toast/alert or call an existing logger) and return early; before setting
window.location.href prompt the user for confirmation (confirm dialog or modal)
and only navigate when confirmed. Ensure to reference the existing
redirectToCHOReport method, sessionstorage.getItem('loginDataResponse'),
environment.dhisURL and dhistoken when making these changes.

maxlength="50"
name="geneticDisorder"
formControlName="geneticDisorder"
(selectionChange)="trackFieldInteraction('Genetic Disorder Type')"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix incorrect event binding on input element.

Line 185 uses (selectionChange) on an <input> element, but selectionChange is only available on <mat-select> elements. This will cause the tracking call to never fire.

🔎 Proposed fix
            <input
              autocomplete="off"
              matInput
              allowText="inputFieldValidator "
              defaultNull
              maxlength="50"
              name="geneticDisorder"
              formControlName="geneticDisorder"
-              (selectionChange)="trackFieldInteraction('Genetic Disorder Type')"
+              (focus)="trackFieldInteraction('Genetic Disorder Type')"
            />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
(selectionChange)="trackFieldInteraction('Genetic Disorder Type')"
<input
autocomplete="off"
matInput
allowText="inputFieldValidator "
defaultNull
maxlength="50"
name="geneticDisorder"
formControlName="geneticDisorder"
(focus)="trackFieldInteraction('Genetic Disorder Type')"
/>
🤖 Prompt for AI Agents
In
@src/app/app-modules/nurse-doctor/history/general-opd-history/family-history/family-history.component.html
at line 185, The template incorrectly uses the (selectionChange) event on an
<input> element so trackFieldInteraction('Genetic Disorder Type') never fires;
update the binding on that input to a supported event such as (input) or
(change) (e.g., replace (selectionChange) with (input) or (change)) so the
trackFieldInteraction call is invoked when the input value changes; confirm you
are editing the template line containing the <input> with the
trackFieldInteraction call and not a <mat-select> element.

Comment on lines +3024 to 3026
getUserId(userName: any) {
return this.http.get(environment.getUserId + userName);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Search for getUserId in environment configuration files
find src/environments -type f -name "*.ts" -o -name "*.js" | head -20

Repository: PSMRI/HWC-UI

Length of output: 247


🏁 Script executed:

# Search for getUserId across environment files
rg -n 'getUserId' src/environments/ 2>/dev/null || echo "Pattern not found in environments directory"

Repository: PSMRI/HWC-UI

Length of output: 147


🏁 Script executed:

# Check doctor.service.ts for context around lines 3024-3026
wc -l src/app/app-modules/nurse-doctor/shared/services/doctor.service.ts

Repository: PSMRI/HWC-UI

Length of output: 127


🏁 Script executed:

# Check each environment file for getUserId
for env_file in src/environments/environment.dev.ts src/environments/environment.development.ts src/environments/environment.local.ts src/environments/environment.prod.ts src/environments/environment.test.ts; do
  echo "=== $env_file ==="
  rg -n 'getUserId' "$env_file" 2>/dev/null || echo "Not found"
done

Repository: PSMRI/HWC-UI

Length of output: 337


🏁 Script executed:

# Read the method around lines 3024-3026 with context
sed -n '3020,3035p' src/app/app-modules/nurse-doctor/shared/services/doctor.service.ts

Repository: PSMRI/HWC-UI

Length of output: 511


🏁 Script executed:

# Check imports at the top of doctor.service.ts
head -50 src/app/app-modules/nurse-doctor/shared/services/doctor.service.ts

Repository: PSMRI/HWC-UI

Length of output: 2010


Add getUserId to all standard environment files and fix type safety.

The method references environment.getUserId, which is defined only in the CI template file but is missing from standard environment files (dev, development, local, prod, test). Additionally, the parameter and return type lack proper type annotations.

Proposed fix
- getUserId(userName: any) {
-   return this.http.get(environment.getUserId + userName);
+ getUserId(userName: string): Observable<any> {
+   return this.http.get(environment.getUserId + userName);
  }

Ensure getUserId is configured in all environment files and update the method signature with explicit types.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
getUserId(userName: any) {
return this.http.get(environment.getUserId + userName);
}
getUserId(userName: string): Observable<any> {
return this.http.get(environment.getUserId + userName);
}
🤖 Prompt for AI Agents
In @src/app/app-modules/nurse-doctor/shared/services/doctor.service.ts around
lines 3024 - 3026, Add a missing environment key and tighten types: add a
getUserId: string entry to all standard environment files (dev, development,
local, prod, test) so environment.getUserId exists at runtime, then update the
doctor service method signature getUserId(userName: any) to use a concrete
parameter type (e.g., userName: string) and a typed Observable return (e.g.,
Observable<any> or a specific interface like Observable<{userId: string}>), and
call HttpClient.get with the generic type and a safe concatenation/encoding of
environment.getUserId + userName; refer to the getUserId method and
environment.getUserId symbol names when making these changes.

Comment on lines +151 to +153
if (err?.handled) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify that the HTTP interceptor sets the 'handled' property on errors

# Search for where the 'handled' property is set in the HTTP interceptor
rg -nP --type=ts -C5 'handled\s*[=:]' src/app/app-modules/core/services/http-interceptor.service.ts

Repository: PSMRI/HWC-UI

Length of output: 38


🏁 Script executed:

#!/bin/bash
# Check if the file exists and search for it
echo "=== Checking for HTTP interceptor files ==="
find . -name "*interceptor*" -type f

echo ""
echo "=== Searching entire codebase for 'handled' property being set ==="
rg -nP --type=ts 'handled\s*[=:]' -C3

echo ""
echo "=== Searching for where 'handled' is referenced ==="
rg -n --type=ts 'handled' src/app/app-modules/pharmacist/worklist/worklist.component.ts

Repository: PSMRI/HWC-UI

Length of output: 316


🏁 Script executed:

#!/bin/bash
# Read the HTTP interceptor service to see what's implemented
cat -n src/app/app-modules/core/services/http-interceptor.service.ts

Repository: PSMRI/HWC-UI

Length of output: 8390


🏁 Script executed:

#!/bin/bash
# Read the worklist component around lines 151-153 to understand context
sed -n '140,165p' src/app/app-modules/pharmacist/worklist/worklist.component.ts

Repository: PSMRI/HWC-UI

Length of output: 858


Remove the dead code check or implement proper error handling in the HTTP interceptor.

The if (err?.handled) check at lines 151-153 will never execute because the HTTP interceptor does not set the handled property on error objects. The interceptor at line 113 simply returns throwError(error.error) without modifying the error object. This results in dead code—the early return will never trigger and the alert will always execute regardless.

Either:

  1. Remove the unused check and let the alert always display for this error scenario, or
  2. Implement proper error handling in the HTTP interceptor to set the handled property on errors that should not trigger additional alerts.
🤖 Prompt for AI Agents
In @src/app/app-modules/pharmacist/worklist/worklist.component.ts around lines
151 - 153, The if (err?.handled) check in worklist.component.ts is dead because
the HTTP interceptor's intercept method currently does throwError(error.error)
without setting handled; either remove this unused conditional from the
component so the alert always runs, or update the interceptor's intercept (or
its error handling path) to attach a handled: true flag onto the error object it
emits (e.g., wrap/clone error.error as { ...error.error, handled: true } before
calling throwError) so the component can rely on err.handled to suppress alerts.

@5Amogh 5Amogh merged commit b240fb9 into main Jan 7, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants